home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / gtlayout-source.lha / LT_NewMenuTemplate.c < prev    next >
C/C++ Source or Header  |  1996-08-22  |  3KB  |  125 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #ifdef DO_MENUS
  15.  
  16. /****** gtlayout.library/LT_NewMenuTemplate ******************************************
  17. *
  18. *   NAME
  19. *    LT_NewMenuTemplate -- Allocate and layout menu items (V11)
  20. *
  21. *   SYNOPSIS
  22. *    Menu = LT_NewMenuTemplate(Screen,TextAttr,AmigaGlyph,CheckmarkGlyph,
  23. *     D0                         A0      A1        A2           A3
  24. *
  25. *                              Error,MenuTemplate);
  26. *                                D0      D1
  27. *
  28. *    struct Menu *LT_NewMenuTemplate(struct Screen *,struct TextAttr *,
  29. *                                    struct Image *,struct Image *,
  30. *                                    LONG *,struct NewMenu *);
  31. *
  32. *   FUNCTION
  33. *    Allocates Menus and MenuItems similar to LT_LayoutMenus().
  34. *
  35. *    As of v18 this routine will validate menu mutual exclusion
  36. *    information.
  37. *
  38. *   INPUTS
  39. *    Screen - Pointer to the screen the menu will appear on. This
  40. *        parameter is required and must not be omitted.
  41. *
  42. *    TextAttr - Pointer to the TextAttr that should be used to
  43. *        layout the menus. If this parameter is omitted,
  44. *        Screen->Font will be used instead.
  45. *
  46. *    AmigaGlyph - Pointer to the Image to use as the Amiga glyph.
  47. *        This parameter may be omitted.
  48. *
  49. *            NOTE: Ignored by intuition.library v37 and below.
  50. *
  51. *    CheckmarkGlyph - Pointer to the Image to use as the checkmark
  52. *        glyph. This parameter may be omitted.
  53. *
  54. *    Error - Pointer to receive error code in case the menu
  55. *        creation or layout process fails. This parameter
  56. *        may be omitted.
  57. *
  58. *    MenuTemplate - Pointer to a series of NewMenu structures,
  59. *        just as you would pass to
  60. *        gtlayout.library/LT_LayoutMenuA.
  61. *
  62. *   RESULT
  63. *    Menu - Pointer to Menu structure, ready to pass to
  64. *        SetMenuStrip(), NULL on failure.
  65. *
  66. *   NOTES
  67. *    The menu created by this function cannot be used with the
  68. *    routines LT_MenuControlTagList, LT_FindMenuCommand and
  69. *    LT_GetMenuItem.
  70. *
  71. *    You may freely add, remove, spindle & mutilate the contents of the
  72. *    menu strip created, just don't trash or disconnect the base menu
  73. *    entry this routine creates as all menu memory tracking data is
  74. *    connected with it.
  75. *
  76. *   SEE ALSO
  77. *    gtlayout.library/LT_DisposeMenu
  78. *    gtlayout.library/LT_LayoutMenuA
  79. *    gtlayout.library/LT_NewMenuTagList
  80. *    intuition.library/SetMenuStrip
  81. *
  82. ******************************************************************************
  83. *
  84. */
  85.  
  86. struct Menu * LIBENT
  87. LT_NewMenuTemplate(REG(a0) struct Screen *Screen,REG(a1) struct TextAttr *TextAttr,REG(a2) struct Image *AmigaGlyph,REG(a3) struct Image *CheckGlyph,REG(d0) LONG *ErrorPtr,REG(d1) struct NewMenu *MenuTemplate)
  88. {
  89.     LONG Error;
  90.  
  91.     if(ErrorPtr)
  92.         *ErrorPtr = 0;
  93.  
  94.     if(MenuTemplate)
  95.     {
  96.         RootMenu *Root;
  97.  
  98.         if(Root = LTP_NewMenu(Screen,TextAttr,AmigaGlyph,CheckGlyph,&Error))
  99.         {
  100.                 // Create the menu
  101.  
  102.             if(LTP_CreateMenuTemplate(Root,&Error,MenuTemplate))
  103.             {
  104.                     // Do the layout
  105.  
  106.                 if(LTP_LayoutMenu(Root,2,2))
  107.                     return(&Root->Menu);
  108.                 else
  109.                     Error = ERROR_DISK_FULL;
  110.             }
  111.  
  112.             LT_DisposeMenu(&Root->Menu);
  113.         }
  114.     }
  115.     else
  116.         Error = ERROR_REQUIRED_ARG_MISSING;
  117.  
  118.     if(ErrorPtr)
  119.         *ErrorPtr = Error;
  120.  
  121.     return(NULL);
  122. }
  123.  
  124. #endif    /* DO_MENUS */
  125.